﻿@model PageListClient<CommentClientModel>

@{
    ViewBag.Title = "Comment";
}

<h2>Comment</h2>

<div id="divComment-j">
    <div data-bind="foreach: models"> 
        <a data-bind='text: topicTitle, attr: { href: "/topic/show/"+topicId() }'></a>
        <div data-bind="html: topicSubTitle"></div>
        <div class="pull-right" >
            <img data-bind='attr: {src: topicThumbnail}' />
        </div>
        <div data-bind='attr: {id:"comment-view-holder_"+$index()}'>
            <p data-bind='click:fn.commentEditButtonClick.bind($data, $index())' class="pull-right" ><i class="icon-pencil"></i>@LocaleResources["App.Edit"]</p>
            <div data-bind='html: content'  class="comment-view-content-j"></div>
        </div>
    </div>
    <div data-bind="pagination:'/api/user/comment'"></div>
</div>
<div id="comment-edit-holder-j">
    <textarea></textarea>
    <button class="comment-edit-save-j">@LocaleResources["App.Save"]</button>
    <button class="comment-edit-cancel-j">@LocaleResources["App.Cancel"]</button>
</div>
@{
    ScriptRegister.AddJson("pageComments", Model);
    ScriptRegister.AddKnockOutBinding("pageComments", "#divComment-j");
    Model.GenerateUniqueId();
 }  
<script type="text/javascript">
    amplify.subscribe($ca.notification.pageIndexChanged + '@Model.UniqueId', function (event) {
        var url = event.url + '/' + event.pageIndex;
        pageComments.basicTargetModelAjax(url, null, pageComments, { type: 'GET' });
    });
</script>
